package org.frame.otherdp;

import java.util.ArrayList;
import java.util.List;
//此类是指过滤链的定义
public class FilterChain {
    private List<Filter> filters = new ArrayList<>();
    private Target target;


    public void addFilter(Filter filter){
        filters.add(filter);
    }

    public void setTarget(Target target) {
        this.target = target;
    }
//链式执行，然后目标类再执行
    public void execute(String request){
        for (Filter f : filters) {
            f.execute(request);
        }
        target.execute(request);
    }
}
